<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <link rel="stylesheet" href="${ctx}/public/css/bootstrap.min.css">
</head>
<body>
<div>
    <ul class="pagination">
        <%--            当前页为第一页时，首页和上一页不能点击。下一页和末页同理--%>
        <c:choose>
            <c:when test="${page.pageNo == 1 or page.pageNo == 0}">
                <li class="disabled"><a href="#">首页</a></li>
                <li class="disabled"><a href="#">上一页</a></li>
            </c:when>
            <c:otherwise>
                <li><a href="javascript:turnPage(1)">首页</a>
                </li>
                <li>
                    <a href="javascript:turnPage(${page.pageNo-1})">上一页</a>
                </li>
            </c:otherwise>
        </c:choose>
        <c:forEach items="${rainbow}" var="rainbow" varStatus="status">
            <c:if test="${page.pageNo == rainbow}">
                <li class="active"><a
                        href="javascript:turnPage(${page.pageNo})">${rainbow}</a>
                </li>
            </c:if>
            <c:if test="${page.pageNo != rainbow}">
                <li>
                    <a href="javascript:turnPage(${rainbow})">${rainbow}</a>
                </li>
            </c:if>
        </c:forEach>
        <c:choose>
            <c:when test="${page.totalPages == 0}">
                <li class="disabled"><a href="#">下一页</a></li>
                <li class="disabled"><a href="#">末页</a>
                </li>
            </c:when>
            <c:when test="${page.pageNo == page.totalPages}">
                <li class="disabled"><a href="#">下一页</a></li>
                <li class="disabled"><a href="#">末页</a>
                </li>
            </c:when>

            <c:otherwise>
                <li>
                    <a href="javascript:turnPage(${page.pageNo + 1})">下一页</a>
                </li>
                <li>
                    <a href="javascript:turnPage(${page.totalPages})">末页</a>
                </li>
            </c:otherwise>
        </c:choose>
        <li class="disabled"><a href="#">第${page.pageNo}页/共${page.totalPages}页</a>
        </li>
        <li class="disabled"><a href="#">共${page.totalRows}条记录</a>
        </li>
    </ul>
</div>
</body>
</html>
